package com.dtx.dao;

import com.dtx.domain.Exam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface IExamDao {

    @Select("select * from midexam where flag=1")
    List<Exam> findAll() throws Exception;

    @Select("select * from midexam where flag=1 and id = #{id}")
    Exam findById(Integer id) throws Exception;

    @Insert("insert into midexam(name,xA,xB,xC,xD,correct,fenlei,zhenti) values(#{name},#{xA},#{xB},#{xC},#{xD},#{correct},#{fenlei},#{zhenti})")
    void save(Exam exam) throws Exception;

    @Update("update midexam set flag=0 where id = #{id}")
    void deleteExamById(Integer id) throws Exception;

    @Update("update midexam set name=#{name},xA=#{xA},xB=#{xB},xC=#{xC},xD=#{xD},correct=#{correct},fenlei=#{fenlei},zhenti=#{zhenti} where id = #{id}")
    void update(Exam exam) throws Exception;


    //@Select("select * from exam where name = '%${value}%'")
    @Select("select * from midexam where flag=1 and name like #{name}")
    List<Exam> findExamByName(String name) throws Exception;
}
